<?php
$servername = "localhost";
$username = "";
$password = "";
$dbname = "";

$conn = new mysqli($servername, $username, $password, $dbname);

if ($conn->connect_error) {
    die("连接失败: " . $conn->connect_error);
}
$conn->set_charset("utf8");
$id = file_get_contents("php://input");

$sql = "SELECT * FROM user WHERE id = '$id'";
$result = $conn->query($sql);

if ($result->num_rows > 0) {
    $row = $result->fetch_assoc();
    $response = array(
        'id' => $row['id'],
        'name' => $row['name'],
        'college'=>$row['college'],
        'grade'=>$row['grade'],
        'authority'=>$row['authority'],
    );
    echo json_encode($response);
} else {
     $response = array('error' => '未找到数据');
    echo json_encode($response,JSON_UNESCAPED_UNICODE);
}

$conn->close();
?>
